﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using WeiTap.Validator.PropertyValidators;
using WeiTap.Validator.Result;

namespace WeiTap.Validator
{
    public interface IValidationRule
    {
        IEnumerable<IPropertyValidator> Validators { get; }
        string RuleSet { get; set; }
        IEnumerable<ValidationFailure> Validate(ValidationContext context);
        Task<IEnumerable<ValidationFailure>> ValidateAsync(ValidationContext context, CancellationToken token = new CancellationToken());
        void ApplyCondition(Func<object, bool> predicate, ApplyConditionTo condition = ApplyConditionTo.AllValidators);
        void ApplyAsyncCondition(Func<object, Task<bool>> predicate, ApplyConditionTo condition = ApplyConditionTo.AllValidators);

    }

    public enum ApplyConditionTo
    {
        AllValidators,
        CurrentValidator
    }
}